3.7.82 \(\int (a+i a \tan (e+f x))^2 (A+B \tan (e+f x)) \, dx\) [682]

Optimal. Leaf size=80 \[ 2 a^2 (A-i B) x-\frac {2 a^2 (i A+B) \log (\cos (e+f x))}{f}-\frac {a^2 (A-i B) \tan (e+f x)}{f}+\frac {B (a+i a \tan (e+f x))^2}{2 f} \]

[Out]

2*a^2*(A-I*B)*x-2*a^2*(I*A+B)*ln(cos(f*x+e))/f-a^2*(A-I*B)*tan(f*x+e)/f+1/2*B*(a+I*a*tan(f*x+e))^2/f

________________________________________________________________________________________

Rubi [A]
time = 0.05, antiderivative size = 80, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, integrand size = 26, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.115, Rules used = {3608, 3558, 3556} \begin {gather*} -\frac {a^2 (A-i B) \tan (e+f x)}{f}-\frac {2 a^2 (B+i A) \log (\cos (e+f x))}{f}+2 a^2 x (A-i B)+\frac {B (a+i a \tan (e+f x))^2}{2 f} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[(a + I*a*Tan[e + f*x])^2*(A + B*Tan[e + f*x]),x]

[Out]

2*a^2*(A - I*B)*x - (2*a^2*(I*A + B)*Log[Cos[e + f*x]])/f - (a^2*(A - I*B)*Tan[e + f*x])/f + (B*(a + I*a*Tan[e
 + f*x])^2)/(2*f)

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3558

Int[((a_) + (b_.)*tan[(c_.) + (d_.)*(x_)])^2, x_Symbol] :> Simp[(a^2 - b^2)*x, x] + (Dist[2*a*b, Int[Tan[c + d
*x], x], x] + Simp[b^2*(Tan[c + d*x]/d), x]) /; FreeQ[{a, b, c, d}, x]

Rule 3608

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[d*(
(a + b*Tan[e + f*x])^m/(f*m)), x] + Dist[(b*c + a*d)/b, Int[(a + b*Tan[e + f*x])^m, x], x] /; FreeQ[{a, b, c,
d, e, f, m}, x] && NeQ[b*c - a*d, 0] && EqQ[a^2 + b^2, 0] &&  !LtQ[m, 0]

Rubi steps

\begin {align*} \int (a+i a \tan (e+f x))^2 (A+B \tan (e+f x)) \, dx &=\frac {B (a+i a \tan (e+f x))^2}{2 f}-(-A+i B) \int (a+i a \tan (e+f x))^2 \, dx\\ &=2 a^2 (A-i B) x-\frac {a^2 (A-i B) \tan (e+f x)}{f}+\frac {B (a+i a \tan (e+f x))^2}{2 f}+\left (2 a^2 (i A+B)\right ) \int \tan (e+f x) \, dx\\ &=2 a^2 (A-i B) x-\frac {2 a^2 (i A+B) \log (\cos (e+f x))}{f}-\frac {a^2 (A-i B) \tan (e+f x)}{f}+\frac {B (a+i a \tan (e+f x))^2}{2 f}\\ \end {align*}

________________________________________________________________________________________

Mathematica [B] Both result and optimal contain complex but leaf count is larger than twice the leaf count of optimal. \(263\) vs. \(2(80)=160\).
time = 1.16, size = 263, normalized size = 3.29 \begin {gather*} \frac {a^2 \sec (e) \sec ^2(e+f x) (\cos (2 f x)+i \sin (2 f x)) \left (-8 (A-i B) \text {ArcTan}(\tan (3 e+f x)) \cos (e) \cos ^2(e+f x)-i \left (4 i A f x \cos (3 e+2 f x)+4 B f x \cos (3 e+2 f x)+(i A+B) \cos (e+2 f x) \left (4 f x-i \log \left (\cos ^2(e+f x)\right )\right )+A \cos (3 e+2 f x) \log \left (\cos ^2(e+f x)\right )-i B \cos (3 e+2 f x) \log \left (\cos ^2(e+f x)\right )+2 \cos (e) \left (-i B+4 i A f x+4 B f x+(A-i B) \log \left (\cos ^2(e+f x)\right )\right )+2 i A \sin (e)+4 B \sin (e)-2 i A \sin (e+2 f x)-4 B \sin (e+2 f x)\right )\right )}{4 f (\cos (f x)+i \sin (f x))^2} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[(a + I*a*Tan[e + f*x])^2*(A + B*Tan[e + f*x]),x]

[Out]

(a^2*Sec[e]*Sec[e + f*x]^2*(Cos[2*f*x] + I*Sin[2*f*x])*(-8*(A - I*B)*ArcTan[Tan[3*e + f*x]]*Cos[e]*Cos[e + f*x
]^2 - I*((4*I)*A*f*x*Cos[3*e + 2*f*x] + 4*B*f*x*Cos[3*e + 2*f*x] + (I*A + B)*Cos[e + 2*f*x]*(4*f*x - I*Log[Cos
[e + f*x]^2]) + A*Cos[3*e + 2*f*x]*Log[Cos[e + f*x]^2] - I*B*Cos[3*e + 2*f*x]*Log[Cos[e + f*x]^2] + 2*Cos[e]*(
(-I)*B + (4*I)*A*f*x + 4*B*f*x + (A - I*B)*Log[Cos[e + f*x]^2]) + (2*I)*A*Sin[e] + 4*B*Sin[e] - (2*I)*A*Sin[e
+ 2*f*x] - 4*B*Sin[e + 2*f*x])))/(4*f*(Cos[f*x] + I*Sin[f*x])^2)

________________________________________________________________________________________

Maple [A]
time = 0.11, size = 76, normalized size = 0.95

method result size
derivativedivides \(\frac {a^{2} \left (-\frac {B \left (\tan ^{2}\left (f x +e \right )\right )}{2}-A \tan \left (f x +e \right )+2 i B \tan \left (f x +e \right )+\frac {\left (2 i A +2 B \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2}+\left (-2 i B +2 A \right ) \arctan \left (\tan \left (f x +e \right )\right )\right )}{f}\) \(76\)
default \(\frac {a^{2} \left (-\frac {B \left (\tan ^{2}\left (f x +e \right )\right )}{2}-A \tan \left (f x +e \right )+2 i B \tan \left (f x +e \right )+\frac {\left (2 i A +2 B \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2}+\left (-2 i B +2 A \right ) \arctan \left (\tan \left (f x +e \right )\right )\right )}{f}\) \(76\)
norman \(\left (-2 i B \,a^{2}+2 a^{2} A \right ) x -\frac {\left (-2 i B \,a^{2}+a^{2} A \right ) \tan \left (f x +e \right )}{f}-\frac {a^{2} B \left (\tan ^{2}\left (f x +e \right )\right )}{2 f}+\frac {\left (i A \,a^{2}+a^{2} B \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{f}\) \(87\)
risch \(\frac {4 i a^{2} B e}{f}-\frac {4 a^{2} A e}{f}-\frac {2 a^{2} \left (i A \,{\mathrm e}^{2 i \left (f x +e \right )}+3 B \,{\mathrm e}^{2 i \left (f x +e \right )}+i A +2 B \right )}{f \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )^{2}}-\frac {2 a^{2} \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) B}{f}-\frac {2 i a^{2} \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) A}{f}\) \(120\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a+I*a*tan(f*x+e))^2*(A+B*tan(f*x+e)),x,method=_RETURNVERBOSE)

[Out]

1/f*a^2*(-1/2*B*tan(f*x+e)^2-A*tan(f*x+e)+2*I*B*tan(f*x+e)+1/2*(2*B+2*I*A)*ln(1+tan(f*x+e)^2)+(2*A-2*I*B)*arct
an(tan(f*x+e)))

________________________________________________________________________________________

Maxima [A]
time = 0.55, size = 75, normalized size = 0.94 \begin {gather*} -\frac {B a^{2} \tan \left (f x + e\right )^{2} - 4 \, {\left (f x + e\right )} {\left (A - i \, B\right )} a^{2} - 2 \, {\left (i \, A + B\right )} a^{2} \log \left (\tan \left (f x + e\right )^{2} + 1\right ) + 2 \, {\left (A - 2 i \, B\right )} a^{2} \tan \left (f x + e\right )}{2 \, f} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+I*a*tan(f*x+e))^2*(A+B*tan(f*x+e)),x, algorithm="maxima")

[Out]

-1/2*(B*a^2*tan(f*x + e)^2 - 4*(f*x + e)*(A - I*B)*a^2 - 2*(I*A + B)*a^2*log(tan(f*x + e)^2 + 1) + 2*(A - 2*I*
B)*a^2*tan(f*x + e))/f

________________________________________________________________________________________

Fricas [A]
time = 1.73, size = 127, normalized size = 1.59 \begin {gather*} -\frac {2 \, {\left ({\left (i \, A + 3 \, B\right )} a^{2} e^{\left (2 i \, f x + 2 i \, e\right )} + {\left (i \, A + 2 \, B\right )} a^{2} + {\left ({\left (i \, A + B\right )} a^{2} e^{\left (4 i \, f x + 4 i \, e\right )} + 2 \, {\left (i \, A + B\right )} a^{2} e^{\left (2 i \, f x + 2 i \, e\right )} + {\left (i \, A + B\right )} a^{2}\right )} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right )\right )}}{f e^{\left (4 i \, f x + 4 i \, e\right )} + 2 \, f e^{\left (2 i \, f x + 2 i \, e\right )} + f} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+I*a*tan(f*x+e))^2*(A+B*tan(f*x+e)),x, algorithm="fricas")

[Out]

-2*((I*A + 3*B)*a^2*e^(2*I*f*x + 2*I*e) + (I*A + 2*B)*a^2 + ((I*A + B)*a^2*e^(4*I*f*x + 4*I*e) + 2*(I*A + B)*a
^2*e^(2*I*f*x + 2*I*e) + (I*A + B)*a^2)*log(e^(2*I*f*x + 2*I*e) + 1))/(f*e^(4*I*f*x + 4*I*e) + 2*f*e^(2*I*f*x
+ 2*I*e) + f)

________________________________________________________________________________________

Sympy [A]
time = 0.32, size = 122, normalized size = 1.52 \begin {gather*} - \frac {2 i a^{2} \left (A - i B\right ) \log {\left (e^{2 i f x} + e^{- 2 i e} \right )}}{f} + \frac {- 2 i A a^{2} - 4 B a^{2} + \left (- 2 i A a^{2} e^{2 i e} - 6 B a^{2} e^{2 i e}\right ) e^{2 i f x}}{f e^{4 i e} e^{4 i f x} + 2 f e^{2 i e} e^{2 i f x} + f} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+I*a*tan(f*x+e))**2*(A+B*tan(f*x+e)),x)

[Out]

-2*I*a**2*(A - I*B)*log(exp(2*I*f*x) + exp(-2*I*e))/f + (-2*I*A*a**2 - 4*B*a**2 + (-2*I*A*a**2*exp(2*I*e) - 6*
B*a**2*exp(2*I*e))*exp(2*I*f*x))/(f*exp(4*I*e)*exp(4*I*f*x) + 2*f*exp(2*I*e)*exp(2*I*f*x) + f)

________________________________________________________________________________________

Giac [B] Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 228 vs. \(2 (73) = 146\).
time = 0.58, size = 228, normalized size = 2.85 \begin {gather*} -\frac {2 \, {\left (i \, A a^{2} e^{\left (4 i \, f x + 4 i \, e\right )} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right ) + B a^{2} e^{\left (4 i \, f x + 4 i \, e\right )} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right ) + 2 i \, A a^{2} e^{\left (2 i \, f x + 2 i \, e\right )} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right ) + 2 \, B a^{2} e^{\left (2 i \, f x + 2 i \, e\right )} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right ) + i \, A a^{2} e^{\left (2 i \, f x + 2 i \, e\right )} + 3 \, B a^{2} e^{\left (2 i \, f x + 2 i \, e\right )} + i \, A a^{2} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right ) + B a^{2} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right ) + i \, A a^{2} + 2 \, B a^{2}\right )}}{f e^{\left (4 i \, f x + 4 i \, e\right )} + 2 \, f e^{\left (2 i \, f x + 2 i \, e\right )} + f} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+I*a*tan(f*x+e))^2*(A+B*tan(f*x+e)),x, algorithm="giac")

[Out]

-2*(I*A*a^2*e^(4*I*f*x + 4*I*e)*log(e^(2*I*f*x + 2*I*e) + 1) + B*a^2*e^(4*I*f*x + 4*I*e)*log(e^(2*I*f*x + 2*I*
e) + 1) + 2*I*A*a^2*e^(2*I*f*x + 2*I*e)*log(e^(2*I*f*x + 2*I*e) + 1) + 2*B*a^2*e^(2*I*f*x + 2*I*e)*log(e^(2*I*
f*x + 2*I*e) + 1) + I*A*a^2*e^(2*I*f*x + 2*I*e) + 3*B*a^2*e^(2*I*f*x + 2*I*e) + I*A*a^2*log(e^(2*I*f*x + 2*I*e
) + 1) + B*a^2*log(e^(2*I*f*x + 2*I*e) + 1) + I*A*a^2 + 2*B*a^2)/(f*e^(4*I*f*x + 4*I*e) + 2*f*e^(2*I*f*x + 2*I
*e) + f)

________________________________________________________________________________________

Mupad [B]
time = 8.54, size = 76, normalized size = 0.95 \begin {gather*} \frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,\left (2\,B\,a^2+A\,a^2\,2{}\mathrm {i}\right )}{f}+\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (a^2\,\left (B+A\,1{}\mathrm {i}\right )\,1{}\mathrm {i}+B\,a^2\,1{}\mathrm {i}\right )}{f}-\frac {B\,a^2\,{\mathrm {tan}\left (e+f\,x\right )}^2}{2\,f} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((A + B*tan(e + f*x))*(a + a*tan(e + f*x)*1i)^2,x)

[Out]

(log(tan(e + f*x) + 1i)*(A*a^2*2i + 2*B*a^2))/f + (tan(e + f*x)*(a^2*(A*1i + B)*1i + B*a^2*1i))/f - (B*a^2*tan
(e + f*x)^2)/(2*f)

________________________________________________________________________________________